#!/usr/bin/perl

# ---------- Init variables -------
#my $version = "0.0001";
# ---------- external readable parameters -------
## Functions
##-------------------------------------------------------
#
# stict syntax checking.
use strict;
use CGI qw(param);
use SNMP_util;
use SIM_cgi;
use SIM_base;
use SIM_settings;
use SIM_nodeInfo;

#BEGIN { $Exporter::Verbose=1 }

# Startupscript translater
my $tool = $ARGV[0];
my $action = $ARGV[1];
my $ipAddr = $ARGV[2];
my $option2 = $ARGV[3];
my $option3 = $ARGV[4];
#print("tool=$tool, action=$action, ipAddr=$ipAddr");
printMenu("snmp", "line", "snmp", $action, $ipAddr);
print("</TD></TR></TABLE>");


my $backHeader="black";
my $httpUser = $ENV{'REMOTE_USER'};
my $httpReF = $ENV{'HTTP_REFERER'};
my $httpScriptName = $ENV{'SCRIPT_NAME'};
my $httpUserIp = $ENV{'REMOTE_ADDR'};
my $httpServerName = $ENV{'HTTP_HOST'};
my $httpCookie = $ENV{'HTTP_COOKIE'};
my $httpHost = $ENV{'HTTP_HOST'};
my $ipDataBase = "$ENV{'SIM_IPDATAB'}" || die "Oops no env found for SIM_IPDATAB.";

# SNMP settings to prevent error logging.
$SNMP_Session::suppress_warnings = 1000;


sub catFile {
  my $output = "";
  my ($file) = @_;
  open FH, $file or $output = "none";
# $output = readline FH;
  $output = <FH>;
  close FH;
  return $output;
}

sub catFileLine {
  my $outPut = "";
  my ($file) = @_;
  open FH, $file or $outPut = "$file";
  $outPut = <FH>;
  close FH;
  chomp($outPut);  # remove the newline
  return $outPut;
}

sub printFileLine {
  my $file = "@_[0]";
  my $varName = "@_[1]";
  my $rest = "@_[2]";
  my $logFile = "@_[3]";
  my $oldVal = catFileLine ("$file");
# print ("Update file=$file, varName=$varName, content:$rest<BR>");
  if ( "$oldVal" ne "$rest" ) {
    open(OUT, ">$file") || die "cannot create $file: $! (file=$file, varName=$varName, rest=$rest)";
    if ( "$logFile" ne "quiet" ) {
      print ("$varName is gewijzigd, oud:$oldVal nieuw:$rest<BR>");
    }
    print OUT $rest;
    close(OUT);
  }
}

sub getIpDir {
  my $workDir = "@_[0]";
  $workDir =~ s#\.#/#g;
  $workDir = "$ipDataBase/$workDir";
  return $workDir;
}

sub snmpWalk {
  my $ipAddr = "@_[0]";
  my $community = "@_[1]";
  my $oid = "@_[2]";
  my $HOST = $community . "@" . $ipAddr;
  my $SNMPSTR = "$HOST" . ":::::" . "1";
  if ( $oid eq "none" ) {
    $oid = param('oid');
  }
  if ( $oid eq "" ) {
    print("<CENTER><FORM method=post Action=$httpScriptName?$tool+$action+$ipAddr>
      OID: <INPUT NAME=oid SIZE=45 TYPE=text>
      <INPUT TYPE=submit VALUE=\"walk tree\" /></FORM>");
  } else {
    print("<CENTER><H2>Walking tree $oid on $ipAddr.</H2>");
    my @info = &snmpwalk("$SNMPSTR", $oid);
    if ( $#info eq -1 ) {
      print("Testing with snmp version 2c.");
      my $SNMPSTR = "$HOST" . ":::::" . "2c";
      @info = &snmpwalk("$SNMPSTR", $oid);
    }
    if ( $#info eq -1 ) {
      print("No matchin oid's found while walking.");
    } else {
      print("<TABLE>");
      foreach my $line (@info) {
        my ( $oidEntry, $result ) = split(':', $line, 2);
        print("<TR><TD>$oid.<B>$oidEntry</B></TD><TD>=</TD><TD>$result</TD></TR>\n");
      }
      print("</TABLE>");
    }
  }
}

sub getSnmpList {
  my $ipAddr = "@_[0]";
  my $community = "@_[1]";
  my $oidList = "@_[2]";
  my $HOST = $community . "@" . $ipAddr;
  my $SNMPSTR = "$HOST" . ":::::" . "1";
  my @oidQueryList = split(' ', $oidList);
  print("<TABLE>
    <TR BGCOLOR=#FFFF88><TD>Name</TD><TD>Value</TD></TR>");
  foreach my $oidEntry(@oidQueryList) {
    my ( $indexName, $indexOid, $align ) = split(':', $oidEntry);
    my $result = &snmpget("$SNMPSTR", "$indexOid");
    print("<TR><TD BGCOLOR=#FFFFBB>$indexName</TD><TD ALIGN=$align>$result</TD></TR>");
  }
  print("</TABLE>");
}

sub splitArubaClientInfo {
  # this sub will split the oid into an formatted mac and an ip part.
  my $oid = $_[0];
  my ( $mac, $ipAddr, $return );
  my @info = split('\.', $oid);
  my $num = 0;
  foreach my $entry (@info) {
    my $hexPart = sprintf("%02x", $entry);
#   print("$num=$hexPart ");
    if ( $num eq 0 ) {
      $mac = $hexPart;
    } elsif ( $num < 6 ) {
      $mac = "$mac:$hexPart";
    } elsif ( $num eq 6 ) {
      $ipAddr = $entry;
    } else {
      $ipAddr = "$ipAddr.$entry";
    } 
    $num++;
  }
  return("$mac", "$ipAddr");
}

sub make_hex_string {
   my $str = unpack "H*", shift @_;
   $str =~ s/(..)/:$1/g;
   $str =~ s/^://;
   $str;
}

sub getSnmpTable {
  my $ipAddr = "@_[0]";
  my $community = "@_[1]";
  my $oidList = "@_[2]";
  my $HOST = $community . "@" . $ipAddr;
  my $SNMPSTR = "$HOST" . ":::::" . "1";
  my ( $indexEntry, $oidRest ) = split(' ', $oidList, 2);
  my ( $indexName, $indexOid, $indexType ) = split(':', $indexEntry);
  my @indexTable = &snmpwalk("$SNMPSTR", $indexOid);
  print("<TABLE>");
  my @oidQueryTbl = split(' ', $oidRest);
  print("<TR BGCOLOR=#FFFF88>");
  if ( $indexType eq "macAndIp") {
    print("<TD ALIGN=center>macAddr</TD><TD>ipAddr</TD>");
  } else { 
    print("<TD ALIGN=center>$indexType</TD>");
  }
  if ( $indexName eq "arubaClientInfo" ) {
    print("<TD COLSPAN=3 ALIGN=center>$indexName</TD>");
  } else {
    print("<TD ALIGN=center>$indexName</TD>");
  }
  foreach my $entry (@oidQueryTbl) {
    my ( $indexName, $indexOid ) = split(':', $entry);
    print("<TD ALIGN=center>$indexName</TD>");
  }
  print("</TR>");
  foreach my $entry (@indexTable) {
    my ( $index, $name ) = split(':', $entry);
    my ($dispIndex);
    if ( $indexType eq "macAddr") {
      my $macAddr = &oidToMac($index);
      $dispIndex = "<A HREF=$httpScriptName?mon+searchSeed+searchIndex+$macAddr>$macAddr</A>";
    } elsif ( $indexType eq "macAndIp") {
      my ( $macAddr, $ipAddr ) = splitArubaClientInfo($index);
      my $nodeColor = &testNodeStatus($ipAddr);
      $dispIndex = "<A HREF=$httpScriptName?mon+searchSeed+searchIndex+$macAddr>$macAddr</A></TD>
                    <TD BGCOLOR=$nodeColor><A HREF=$httpScriptName?mon+nodestatus+$ipAddr>$ipAddr</A>";
#     $dispIndex = "$macAddr</TD><TD>$ipAddr";
    } else {
      $dispIndex = $index;
      
    }
    print("<TR BGCOLOR=#DDDDDD><TD ALIGN=right>$dispIndex</TD>");
    if ( $indexName eq "ipAddr" ) {
      my $nodeColor = &testNodeStatus($name);
      print("<TD BGCOLOR=$nodeColor><A HREF=$httpScriptName?mon+nodestatus+$name>$name</A></TD>");
    } else {
      print("<TD>$name</TD>");
    }
    foreach my $oidEntry (@oidQueryTbl) {
      my ( $indexName, $indexOid, $align, $postOid ) = split(':', $oidEntry);
      if ( $indexOid eq "intStatus") {
        my ( $bgColor, $status );
        my $operStatus = &snmpget("$SNMPSTR", ".1.3.6.1.2.1.2.2.1.8.$index");
        if ( $operStatus eq "2" ) {
          $bgColor = "#FF0033";
          $status = "down";
        } else {
          my $adminStatus = &snmpget("$SNMPSTR", ".1.3.6.1.2.1.2.2.1.7.$index");
          if ( $adminStatus eq "2" ) {
            $bgColor = "#33FFFF";
            $status = "shut";
          } elsif ( $adminStatus eq "1" ) {
            $bgColor = "#00FF33";
            $status = "up";
          } else {
            $bgColor = "grey";
            $status = "undefined ($adminStatus)";
          }
        }
        print("<TD BGCOLOR=$bgColor ALIGN=center>$status</TD>");
      } else {
        my $testOid;
        if ( $postOid eq "" ) {
          $testOid = "$indexOid.$index";
        } else {
          $testOid = "$indexOid.$index.$postOid";
        }
        my $result = &snmpget("$SNMPSTR", "$testOid");
        # special formatting of output
        my $bgColor = "";
        if ( $align eq "macAddr" ) {
          $align = "";
#         $result = &oidToMac($result);
          $result = &make_hex_string($result);
        } elsif ( $align eq "apPhyType" ) {
          if ( $result eq "1" ) {
            $result = "dot11a";
          } elsif ( $result eq "2" ) {
            $result = "dot11b";
          } elsif ( $result eq "3" ) {
            $result = "dot11g";
          }
        } elsif ( $align eq "status" ) {
          if ( $result eq "1" ) {
            $result = "oke";
            $bgColor = "#00FF33";
          } else {
            $bgColor = "red";
          }
          $align = "center";
        }
        # output data
        if ( $indexName eq "ipAddr" ) {
          my $nodeColor = &testNodeStatus($result);
          print("<TD BGCOLOR=$nodeColor ALIGN=$align><A HREF=$httpScriptName?mon+nodestatus+$result>$result</A></TD>");
        } else {
          print("<TD ALIGN=$align BGCOLOR=$bgColor>$result</TD>");
        }
      }
    }  
    print("</TR>");
  }
  print("</TABLE>");
}

sub FoundryInfo {
  my $ipAddr = "@_[0]";
  my $community = "@_[1]";
  print("<CENTER><H2>CPU load</H2>");
  getSnmpList( $ipAddr, $community, "snAgGblCpuUtil1SecAvg:1.3.6.1.4.1.1991.1.1.2.1.50:right snAgGblCpuUtil5SecAvg:1.3.6.1.4.1.1991.1.1.2.1.51:right snAgGblCpuUtil1MinAvg:1.3.6.1.4.1.1991.1.1.2.1.52:right" );
}

sub arubaInfo {
  my $ipAddr = "@_[0]";
  my $community = "@_[1]";
  # Specifier swFCPortTable names shortened
  print("<CENTER><FONT SIZE=+2><B>Processor info</B></FONT>1.3.6.1.4.1.14823.2.2.1.1.1.9.1<BR>Processor info for the controler.");
  getSnmpTable( $ipAddr, $community, "Processor:.1.3.6.1.4.1.14823.2.2.1.1.1.9.1.2 Load:.1.3.6.1.4.1.14823.2.2.1.1.1.9.1.3");

  print("<P><FONT SIZE=+2><B>Physical accesspoint table</B></FONT>");
  &printEntry2("1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1","walktree ", "snmp+snmpwalk", "snmp+snmpwalk+$ipAddr+1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1", " ", "line", "", "");
  #1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1
  print("<BR>Physical accesspoints / radio devices registered.");
  # more info like floor etc available.
  getSnmpTable( $ipAddr, $community, "ipAddr:.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.2:macAddr name:.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.3 group:.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.4 modelOid:.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.5 serial:.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.6 model:.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.13:center organisation:.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.27 building:.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.24 floor:.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.25 snmpLoc:.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.32 status:.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.19:status upTime:.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.12:right");

  print("<P><FONT SIZE=+2><B>Accesspoint SSID table</B></FONT>");
  &printEntry2("1.3.6.1.4.1.14823.2.2.1.1.3.3.1","walktree ", "snmp+snmpwalk", "snmp+snmpwalk+$ipAddr+1.3.6.1.4.1.14823.2.2.1.1.3.3.1", " ", "line", "", "");
  &printEntry2("1.3.6.1.4.1.14823.2.2.1.1.3.5.1","walktree", "snmp+snmpwalk", "snmp+snmpwalk+$ipAddr+1.3.6.1.4.1.14823.2.2.1.1.3.5.1", " ", "line", "/", "");
  print("<BR>Available SSID's with info and error statistics.");
  getSnmpTable( $ipAddr, $community, "ESSID:.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.2:macAddr ipAddr:.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.5 apPhyType:.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.6:apPhyType channel:.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.8:right noise:.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.13:right signal2noise:.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.14:right txRate:.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.15:right rxRate:.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.16:right BSSTxBytes:.1.3.6.1.4.1.14823.2.2.1.1.3.5.1.9:right BSSRxBytes:.1.3.6.1.4.1.14823.2.2.1.1.3.5.1.11:right BwRate:.1.3.6.1.4.1.14823.2.2.1.1.3.5.1.12:right RetryR:.1.3.6.1.4.1.14823.2.2.1.1.3.5.1.13:right LowSpeedR:.1.3.6.1.4.1.14823.2.2.1.1.3.5.1.14:right NonUnicastR:.1.3.6.1.4.1.14823.2.2.1.1.3.5.1.15:right FragR:.1.3.6.1.4.1.14823.2.2.1.1.3.5.1.16:right RecvErrR:.1.3.6.1.4.1.14823.2.2.1.1.3.5.1.17:right");

# print("<P><FONT SIZE=+2><B>Client table</B></FONT>1.3.6.1.4.1.14823.2.2.1.4.1.2.1.3<BR>Mac and IP info for connected clients.");
# getSnmpTable( $ipAddr, $community, "arubaClientInfo:.1.3.6.1.4.1.14823.2.2.1.4.1.2.1.3:macAndIp");

  print("<P><FONT SIZE=+2><B>wlsxUser table</B></FONT>");
  &printEntry2("1.3.6.1.4.1.14823.2.2.1.4.1.2.1","walktree 1.3.6.1.4.1.14823.2.2.1.4.1.2.1", "snmp+snmpwalk", "snmp+snmpwalk+$ipAddr+1.3.6.1.4.1.14823.2.2.1.4.1.2.1", " ", "line", "", "");
  print("<BR>Info for connected clients.");
  getSnmpTable( $ipAddr, $community, "userName:.1.3.6.1.4.1.14823.2.2.1.4.1.2.1.3:macAndIp userRole:.1.3.6.1.4.1.14823.2.2.1.4.1.2.1.4 authServer:1.3.6.1.4.1.14823.2.2.1.4.1.2.1.8 apLocation:1.3.6.1.4.1.14823.2.2.1.4.1.2.1.10 bssid:1.3.6.1.4.1.14823.2.2.1.4.1.2.1.11:macAddr vlan:.1.3.6.1.4.1.14823.2.2.1.4.1.2.1.22");
}
sub brocadeInfo {
  my $ipAddr = "@_[0]";
  my $community = "@_[1]";
  # Specifier swFCPortTable names shortened
  print("<CENTER><H2>Fiberchannel error counters</H2>");
  getSnmpTable( $ipAddr, $community, "Specifier:.1.3.6.1.4.1.1588.2.1.1.1.6.2.1.37 PortName:.1.3.6.1.4.1.1588.2.1.1.1.6.2.1.36 RxEncInFrs:.1.3.6.1.4.1.1588.2.1.1.1.6.2.1.21:right RxCrcs:.1.3.6.1.4.1.1588.2.1.1.1.6.2.1.22:right RxTruncs:.1.3.6.1.4.1.1588.2.1.1.1.6.2.1.23:right RxTooLongs:.1.3.6.1.4.1.1588.2.1.1.1.6.2.1.24:right RxBadEofs:.1.3.6.1.4.1.1588.2.1.1.1.6.2.1.25:right RxEncOutFrs:.1.3.6.1.4.1.1588.2.1.1.1.6.2.1.26:right RxBadOs:.1.3.6.1.4.1.1588.2.1.1.1.6.2.1.27:right C3Discards:.1.3.6.1.4.1.1588.2.1.1.1.6.2.1.28:right McastTimedOuts:.1.3.6.1.4.1.1588.2.1.1.1.6.2.1.29:right" );
}

sub ciscoDot1xInfo {
  my $ipAddr = "@_[0]";
  my $community = "@_[1]";
  # Specifier swFCPortTable names shortened
  print("<CENTER><H2>Cisco dot1x info</H2>Vlan and username info from the CPAE Mib.");
  getSnmpTable( $ipAddr, $community, "Intname:.1.3.6.1.2.1.2.2.1.2 IntStatus:intStatus OperVlan:.1.3.6.1.4.1.9.9.220.1.1.1.7:right UserName:.1.3.6.1.4.1.9.9.220.1.11.1.4:left:1" );
}

sub CiscoVpn3000 {
  my $ipAddr = "@_[0]";
  my $community = "@_[1]";
  print("<CENTER><H2>Cisco VPN3000 usertable</H2>");
  getSnmpTable( $ipAddr, $community, "user:1.3.6.1.4.1.3076.2.1.2.17.2.1.3 localIp:1.3.6.1.4.1.3076.2.1.2.17.2.1.4 remoteIp:1.3.6.1.4.1.3076.2.1.2.17.2.1.14 connectTime:1.3.6.1.4.1.3076.2.1.2.17.2.1.8:right bytesIn:1.3.6.1.4.1.3076.2.1.2.17.2.1.10:right bytesSent:1.3.6.1.4.1.3076.2.1.2.17.2.1.9:right type:1.3.6.1.4.1.3076.2.1.2.17.2.1.17");
}

sub arpTable {
  my $ipAddr = "@_[0]";
  my $community = "@_[1]";
  my $HOST = $community . "@" . $ipAddr;
  my $SNMPSTR = "$HOST" . ":::::" . "1";
  print("<CENTER><B>Arptable for $ipAddr:</B><TABLE>
    <TR BGCOLOR=#00AAAA><TD>Ip adress</TD><TD>Mac adress</TD></TR>");
  my @arpTable = &snmpwalk("$SNMPSTR", ".1.3.6.1.2.1.4.22.1.2.2");
  foreach my $entry (@arpTable) {
    my ( $ipAddr, $macAddr ) = split(':', $entry);
    $macAddr = unpack('H12', $macAddr);
    my $mac1 = substr($macAddr, 0, 2);
    my $mac2 = substr($macAddr, 2, 2);
    my $mac3 = substr($macAddr, 4, 2);
    my $mac4 = substr($macAddr, 6, 2);
    my $mac5 = substr($macAddr, 8, 2);
    my $mac6 = substr($macAddr, 10, 2);
    $macAddr = "$mac1:$mac2:$mac3:$mac4:$mac5:$mac6";
    print("<TR BGCOLOR=#AAEEEE><TD>$ipAddr</TD><TD>$macAddr</TD></TR>");
  }
  print("</TABLE>");
}

sub catOsModuleTable {
  my $ipAddr = "@_[0]";
  my $community = "@_[1]";
  my $HOST = $community . "@" . $ipAddr;
  my $SNMPSTR = "$HOST" . ":::::" . "1";
  print("<TABLE>");
  foreach my $num ( 1 .. 28 ) {
    print("<TR><TD>$num:</TD>");
    my $test = &snmpget("$SNMPSTR", "1.3.6.1.4.1.9.5.1.3.1.1.2.3");
    my @MODULELIST = &snmpwalk("$SNMPSTR", "1.3.6.1.4.1.9.5.1.3.1.1.$num");
    foreach my $info (@MODULELIST) {
      print("<TD>$info</TD>");
    }
    print("</TR>");
  }
  print("</TABLE>");
}

sub ciscoModuleTable {
  my $ipAddr = "@_[0]";
  my $community = "@_[1]";
  my $HOST = $community . "@" . $ipAddr;
  my $SNMPSTR = "$HOST" . ":::::" . "1";
  print("<TABLE>");
  my @MODULELIST = &snmpwalk("$SNMPSTR", "1.3.6.1.2.1.47.1.1.1.1.13");
  print("<TR BGCOLOR=#AAAAAA>
           <TD>Position</TD>
           <TD>Mod Name</TD>
           <TD>Mod Descr</TD>
           <TD>Firmware</TD>
           <TD>Sw level</TD>
           <TD>Serial</TD>
           <TD>Manufacturer</TD>
         </TR>");
  foreach my $info (@MODULELIST) {
     my ($oidRef, $entPhysicalModelName) = split(':', $info, 2);
#    if ( "$entPhysicalModelName" ne "" ) {
       my $entPhysicalDescr = &snmpget($SNMPSTR, "1.3.6.1.2.1.47.1.1.1.1.2.$oidRef");
       my $entPhysicalName = &snmpget($SNMPSTR, "1.3.6.1.2.1.47.1.1.1.1.7.$oidRef");
       my $entPhysicalFirmwareRev = &snmpget($SNMPSTR, "1.3.6.1.2.1.47.1.1.1.1.9.$oidRef");
       my $entPhysicalSoftwareRev = &snmpget($SNMPSTR, "1.3.6.1.2.1.47.1.1.1.1.10.$oidRef");
       my $entPhysicalSerialNum   = &snmpget($SNMPSTR, "1.3.6.1.2.1.47.1.1.1.1.11.$oidRef");
       my $entPhysicalMfgName     = &snmpget($SNMPSTR, "1.3.6.1.2.1.47.1.1.1.1.12.$oidRef");
       print("<TR>
               <TD>$entPhysicalName</TD>
               <TD>$entPhysicalModelName</TD>
               <TD>$entPhysicalDescr</TD>
               <TD>$entPhysicalFirmwareRev</TD>
               <TD>$entPhysicalSoftwareRev</TD>
               <TD>$entPhysicalSerialNum</TD>
               <TD>$entPhysicalMfgName</TD>
              </TR>");
#   }
  }
  print("</TABLE>");
}

#--------------------------- Main ---------------------------
if ( "$ipAddr" eq "" ) {
  print("Oops, no ip adress found, exiting.....");
  exit;
}
my $ipDir = getIpDir($ipAddr);
if ( ! -d $ipDir ) {
  print("Oops, no definition found for $ipAddr....");
} elsif ( ! -f "$ipDir/snmpcomm.txt" ) {
  print("Oops, no snmp communitystring found, exiting.....");
} else {
  my $hostName = catFileLine("$ipDir/hostname.txt");
  print("<CENTER>Info for: <B><FONT SIZE=+2>$hostName</FONT> 
             <A HREF=$httpScriptName?mon+nodestatus+$ipAddr>$ipAddr</A></B><HR></CENTER>");
  my $community = catFileLine("$ipDir/snmpcomm.txt");
  if ( "$action" eq "ciscoModuleTable" ) {
    ciscoModuleTable("$ipAddr","$community");
    catOsModuleTable("$ipAddr","$community");
  } elsif ( "$action" eq "ciscoDot1x" ) {
    ciscoDot1xInfo("$ipAddr","$community");
  } elsif ( "$action" eq "ciscoVpn" ) {
    CiscoVpn3000("$ipAddr","$community");
  } elsif ( "$action" eq "aruba" ) {
    arubaInfo("$ipAddr","$community");
  } elsif ( "$action" eq "brocade" ) {
    brocadeInfo("$ipAddr","$community");
  } elsif ( "$action" eq "arpTable" ) {
    arpTable("$ipAddr","$community");
  } elsif ( "$action" eq "snmpwalk" ) {
    snmpWalk("$ipAddr","$community", $option2);
  } else {
    system(" $SIMparam{'SIMsnmpTool1'} $action $ipAddr ");
  }
}
